home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume11 / tinymud2 / part10 < prev    next >
Encoding:
Text File  |  1990-08-10  |  39.0 KB  |  1,404 lines

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v11i014:  tinymud2 - user-extendible multi-user adventure (v1.5.4), Part10/10
  5. Message-ID: <6059@tekred.CNA.TEK.COM>
  6. Date: 30 Jul 90 16:47:06 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1393
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: James Aspnes <asp@cs.cmu.edu>
  12. Posting-number: Volume 11, Issue 14
  13. Archive-name: tinymud2/Part10
  14. Supersedes: tinymud: Volume 8, Issue 80-83
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 10 (of 10)."
  25. # Contents:  boolexp.c copyright.h decompress.c do_gripes externs.h
  26. #   help.c help.txt interface.h match.h restart-day restart-night
  27. #   rob.c sanity-check.c small.db.README stringutil.c unparse.c
  28. #   utils.c
  29. # Wrapped by billr@saab on Fri Jul 27 15:27:51 1990
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'boolexp.c' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'boolexp.c'\"
  33. else
  34. echo shar: Extracting \"'boolexp.c'\" \(3952 characters\)
  35. sed "s/^X//" >'boolexp.c' <<'END_OF_FILE'
  36. X#include "copyright.h"
  37. X
  38. X#include <ctype.h>
  39. X
  40. X#include "db.h"
  41. X#include "match.h"
  42. X#include "externs.h"
  43. X#include "config.h"
  44. X#include "interface.h"
  45. X
  46. Xint eval_boolexp(dbref player, struct boolexp *b)
  47. X{
  48. X    if(b == TRUE_BOOLEXP) {
  49. X    return 1;
  50. X    } else {
  51. X    switch(b->type) {
  52. X      case BOOLEXP_AND:
  53. X        return (eval_boolexp(player, b->sub1)
  54. X            && eval_boolexp(player, b->sub2));
  55. X      case BOOLEXP_OR:
  56. X        return (eval_boolexp(player, b->sub1)
  57. X            || eval_boolexp(player, b->sub2));
  58. X      case BOOLEXP_NOT:
  59. X        return !eval_boolexp(player, b->sub1);
  60. X      case BOOLEXP_CONST:
  61. X        return (b->thing == player
  62. X            || member(b->thing, db[player].contents));
  63. X      default:
  64. X        abort();        /* bad type */
  65. X        return 0;
  66. X    }
  67. X    }
  68. X}
  69. X
  70. X/* If the parser returns TRUE_BOOLEXP, you lose */
  71. X/* TRUE_BOOLEXP cannot be typed in by the user; use @unlock instead */
  72. Xstatic const char *parsebuf;
  73. Xstatic dbref parse_player;
  74. X
  75. Xstatic void skip_whitespace(void)
  76. X{
  77. X    while(*parsebuf && isspace(*parsebuf)) parsebuf++;
  78. X}
  79. X
  80. Xstatic struct boolexp *parse_boolexp_E(void); /* defined below */
  81. X
  82. X/* F -> (E); F -> !F; F -> object identifier */
  83. Xstatic struct boolexp *parse_boolexp_F(void)
  84. X{
  85. X    struct boolexp *b;
  86. X    char *p;
  87. X    char buf[BUFFER_LEN];
  88. X    char msg[BUFFER_LEN];
  89. X
  90. X    skip_whitespace();
  91. X    switch(*parsebuf) {
  92. X      case '(':
  93. X    parsebuf++;
  94. X    b = parse_boolexp_E();
  95. X    skip_whitespace();
  96. X    if(b == TRUE_BOOLEXP || *parsebuf++ != ')') {
  97. X        free_boolexp(b);
  98. X        return TRUE_BOOLEXP;
  99. X    } else {
  100. X        return b;
  101. X    }
  102. X    /* break; */
  103. X      case NOT_TOKEN:
  104. X    parsebuf++;
  105. X    b = (struct boolexp *) malloc(sizeof(struct boolexp));
  106. X    b->type = BOOLEXP_NOT;
  107. X    b->sub1 = parse_boolexp_F();
  108. X    if(b->sub1 == TRUE_BOOLEXP) {
  109. X        free((void *) b);
  110. X        return TRUE_BOOLEXP;
  111. X    } else {
  112. X        return b;
  113. X    }
  114. X    /* break */
  115. X      default:
  116. X    /* must have hit an object ref */
  117. X    /* load the name into our buffer */
  118. X    p = buf;
  119. X    while(*parsebuf
  120. X          && *parsebuf != AND_TOKEN
  121. X          && *parsebuf != OR_TOKEN
  122. X          && *parsebuf != ')') {
  123. X        *p++ = *parsebuf++;
  124. X    }
  125. X    /* strip trailing whitespace */
  126. X    *p-- = '\0';
  127. X    while(isspace(*p)) *p-- = '\0';
  128. X
  129. X    b = (struct boolexp *) malloc(sizeof(struct boolexp));
  130. X    b->type = BOOLEXP_CONST;
  131. X
  132. X    /* do the match */
  133. X    init_match(parse_player, buf, TYPE_THING);
  134. X    match_neighbor();
  135. X    match_possession();
  136. X    match_me();
  137. X    match_absolute();
  138. X    match_player();
  139. X    b->thing = match_result();
  140. X
  141. X    if(b->thing == NOTHING) {
  142. X        sprintf(msg, "I don't see %s here.", buf);
  143. X        notify(parse_player, msg);
  144. X        free((void *) b);
  145. X        return TRUE_BOOLEXP;
  146. X    } else if(b->thing == AMBIGUOUS) {
  147. X        sprintf(msg, "I don't know which %s you mean!", buf);
  148. X        notify(parse_player, msg);
  149. X        free((void *) b);
  150. X        return TRUE_BOOLEXP;
  151. X    } else {
  152. X        return b;
  153. X    }
  154. X    /* break */
  155. X    }
  156. X}
  157. X
  158. X/* T -> F; T -> F & T */
  159. Xstatic struct boolexp *parse_boolexp_T(void)
  160. X{
  161. X    struct boolexp *b;
  162. X    struct boolexp *b2;
  163. X
  164. X    if((b = parse_boolexp_F()) == TRUE_BOOLEXP) {
  165. X    return b;
  166. X    } else {
  167. X    skip_whitespace();
  168. X    if(*parsebuf == AND_TOKEN) {
  169. X        parsebuf++;
  170. X
  171. X        b2 = (struct boolexp *) malloc(sizeof(struct boolexp));
  172. X        b2->type = BOOLEXP_AND;
  173. X        b2->sub1 = b;
  174. X        if((b2->sub2 = parse_boolexp_T()) == TRUE_BOOLEXP) {
  175. X        free_boolexp(b2);
  176. X        return TRUE_BOOLEXP;
  177. X        } else {
  178. X        return b2;
  179. X        }
  180. X    } else {
  181. X        return b;
  182. X    }
  183. X    }
  184. X}
  185. X
  186. X/* E -> T; E -> T | E */
  187. Xstatic struct boolexp *parse_boolexp_E(void)
  188. X{
  189. X    struct boolexp *b;
  190. X    struct boolexp *b2;
  191. X
  192. X    if((b = parse_boolexp_T()) == TRUE_BOOLEXP) {
  193. X    return b;
  194. X    } else {
  195. X    skip_whitespace();
  196. X    if(*parsebuf == OR_TOKEN) {
  197. X        parsebuf++;
  198. X
  199. X        b2 = (struct boolexp *) malloc(sizeof(struct boolexp));
  200. X        b2->type = BOOLEXP_OR;
  201. X        b2->sub1 = b;
  202. X        if((b2->sub2 = parse_boolexp_E()) == TRUE_BOOLEXP) {
  203. X        free_boolexp(b2);
  204. X        return TRUE_BOOLEXP;
  205. X        } else {
  206. X        return b2;
  207. X        }
  208. X    } else {
  209. X        return b;
  210. X    }
  211. X    }
  212. X}
  213. X
  214. Xstruct boolexp *parse_boolexp(dbref player, const char *buf)
  215. X{
  216. X    parsebuf = buf;
  217. X    parse_player = player;
  218. X    return parse_boolexp_E();
  219. X}
  220. END_OF_FILE
  221. if test 3952 -ne `wc -c <'boolexp.c'`; then
  222.     echo shar: \"'boolexp.c'\" unpacked with wrong size!
  223. fi
  224. # end of 'boolexp.c'
  225. fi
  226. if test -f 'copyright.h' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'copyright.h'\"
  228. else
  229. echo shar: Extracting \"'copyright.h'\" \(1424 characters\)
  230. sed "s/^X//" >'copyright.h' <<'END_OF_FILE'
  231. X/* -*-C-*-
  232. X
  233. XCopyright (c) 1989, 1990 by David Applegate, James Aspnes, Timothy Freeman,
  234. X                and Bennet Yee.
  235. X
  236. XThis material was developed by the above-mentioned authors.
  237. XPermission to copy this software, to redistribute it, and to use it
  238. Xfor any purpose is granted, subject to the following restrictions and
  239. Xunderstandings.
  240. X
  241. X1. Any copy made of this software must include this copyright notice
  242. Xin full.
  243. X
  244. X2. Users of this software agree to make their best efforts (a) to
  245. Xreturn to the above-mentioned authors any improvements or extensions
  246. Xthat they make, so that these may be included in future releases; and
  247. X(b) to inform the authors of noteworthy uses of this software.
  248. X
  249. X3. All materials developed as a consequence of the use of this
  250. Xsoftware shall duly acknowledge such use, in accordance with the usual
  251. Xstandards of acknowledging credit in academic research.
  252. X
  253. X4. The authors have made no warrantee or representation that the
  254. Xoperation of this software will be error-free, and the authors are
  255. Xunder no obligation to provide any services, by way of maintenance,
  256. Xupdate, or otherwise.
  257. X
  258. X5. In conjunction with products arising from the use of this material,
  259. Xthere shall be no use of the names of the authors, of Carnegie-Mellon
  260. XUniversity, nor of any adaptation thereof in any advertising,
  261. Xpromotional, or sales literature without prior written consent from
  262. Xthe authors and Carnegie-Mellon University in each case. */
  263. X
  264. END_OF_FILE
  265. if test 1424 -ne `wc -c <'copyright.h'`; then
  266.     echo shar: \"'copyright.h'\" unpacked with wrong size!
  267. fi
  268. # end of 'copyright.h'
  269. fi
  270. if test -f 'decompress.c' -a "${1}" != "-c" ; then 
  271.   echo shar: Will not clobber existing file \"'decompress.c'\"
  272. else
  273. echo shar: Extracting \"'decompress.c'\" \(164 characters\)
  274. sed "s/^X//" >'decompress.c' <<'END_OF_FILE'
  275. X#include <stdio.h>
  276. X
  277. Xconst char *uncompress(const char *s);
  278. X
  279. Xint main()
  280. X{
  281. X    char buf[16384];
  282. X
  283. X    while(gets(buf)) {
  284. X    puts(uncompress(buf));
  285. X    }
  286. X    return 0;
  287. X}
  288. END_OF_FILE
  289. if test 164 -ne `wc -c <'decompress.c'`; then
  290.     echo shar: \"'decompress.c'\" unpacked with wrong size!
  291. fi
  292. # end of 'decompress.c'
  293. fi
  294. if test -f 'do_gripes' -a "${1}" != "-c" ; then 
  295.   echo shar: Will not clobber existing file \"'do_gripes'\"
  296. else
  297. echo shar: Extracting \"'do_gripes'\" \(711 characters\)
  298. sed "s/^X//" >'do_gripes' <<'END_OF_FILE'
  299. X#! /bin/sh
  300. X#
  301. X# This shell script should be run by CRON or ATRUN daily to extract
  302. X# 
  303. X#
  304. Xcd /usr/tinymud/lib
  305. X
  306. XADDR=$USER
  307. XLOGFILE=tinymud.log
  308. XGRIPELOG=tinymud.gripes
  309. XTMPFILE=/tmp/allgripes${$}
  310. XNEWGRIPES=/tmp/newgripes${$}
  311. X
  312. X#
  313. X# Long version of logs
  314. X#
  315. X#egrep 'GRIPE from|FORCE:|WIZARD:|BOBBLE:|BOOT:|SHUTDOWN:|ROBOT:' ${LOGFILE} | sort > ${TMPFILE}
  316. X#
  317. X# Short version of logs
  318. X#
  319. Xegrep 'GRIPE from|WIZARD:|SHUTDOWN:' ${LOGFILE} | sort > ${TMPFILE}
  320. X
  321. Xsort -o ${GRIPELOG} ${GRIPELOG}
  322. X
  323. Xcomm -13 ${GRIPELOG} ${TMPFILE} > ${NEWGRIPES}
  324. X
  325. Xif test -s ${NEWGRIPES}
  326. Xthen
  327. X    awk '{print $0;printf "\n"}' ${NEWGRIPES} | \
  328. X        fmt | Mail -s "Daily TinyMUD gripes" ${ADDR}
  329. X    cat ${NEWGRIPES} >> ${GRIPELOG}
  330. Xfi
  331. X
  332. Xrm -f ${TMPFILE} ${NEWGRIPES}
  333. END_OF_FILE
  334. if test 711 -ne `wc -c <'do_gripes'`; then
  335.     echo shar: \"'do_gripes'\" unpacked with wrong size!
  336. fi
  337. chmod +x 'do_gripes'
  338. # end of 'do_gripes'
  339. fi
  340. if test -f 'externs.h' -a "${1}" != "-c" ; then 
  341.   echo shar: Will not clobber existing file \"'externs.h'\"
  342. else
  343. echo shar: Extracting \"'externs.h'\" \(4348 characters\)
  344. sed "s/^X//" >'externs.h' <<'END_OF_FILE'
  345. X#include "copyright.h"
  346. X
  347. X/* Prototypes for externs not defined elsewhere */
  348. X#include "db.h"
  349. X
  350. X/* From create.c */
  351. Xextern void do_open(dbref player, const char *direction, const char *linkto);
  352. Xextern void do_link(dbref player, const char *name, const char *room_name);
  353. Xextern void do_dig(dbref player, const char *name);
  354. Xextern void do_create(dbref player, char *name, int cost);
  355. X
  356. X/* From game.c */
  357. Xextern void do_dump(dbref player);
  358. Xextern void do_shutdown(dbref player);
  359. Xextern void writelog(const char *, ...);
  360. X
  361. X/* From help.c */
  362. Xint spit_file(dbref player, const char *filename);
  363. Xextern void do_help(dbref player);
  364. Xextern void do_news(dbref player);
  365. X
  366. X/* From look.c */
  367. Xextern void look_room(dbref player, dbref room);
  368. Xextern void do_look_around(dbref player);
  369. Xextern void do_look_at(dbref player, const char *name);
  370. Xextern void do_examine(dbref player, const char *name);
  371. Xextern void do_inventory(dbref player);
  372. Xextern void do_find(dbref player, const char *name);
  373. X
  374. X/* From move.c */
  375. Xextern void moveto(dbref what, dbref where);
  376. Xextern void enter_room(dbref player, dbref loc);
  377. Xextern void send_home(dbref thing);
  378. Xextern int can_move(dbref player, const char *direction);
  379. Xextern void do_move(dbref player, const char *direction);
  380. Xextern void do_get(dbref player, const char *what);
  381. Xextern void do_drop(dbref player, const char *name);
  382. X
  383. X/* From player.c */
  384. Xextern dbref lookup_player(const char *name);
  385. Xextern void do_password(dbref player, const char *old, const char *newobj);
  386. X
  387. X/* From predicates.h */
  388. Xextern int can_link_to(dbref who, object_flag_type what, dbref where);
  389. Xextern int could_doit(dbref player, dbref thing);
  390. Xextern int can_doit(dbref player, dbref thing, const char *default_fail_msg);
  391. Xextern int can_see(dbref player, dbref thing, int can_see_location);
  392. Xextern int controls(dbref who, dbref what);
  393. Xextern int payfor(dbref who, int cost);
  394. X
  395. X/* From rob.c */
  396. Xextern void do_kill(dbref player, const char *what, int cost);
  397. Xextern void do_give(dbref player, char *recipient, int amount);
  398. Xextern void do_rob(dbref player, const char *what);
  399. X
  400. X/* From set.c */
  401. Xextern void do_name(dbref player, const char *name, char *newname);
  402. Xextern void do_describe(dbref player, const char *name, const char *description);
  403. Xextern void do_fail(dbref player, const char *name, const char *message);
  404. Xextern void do_success(dbref player, const char *name, const char *message);
  405. Xextern void do_osuccess(dbref player, const char *name, const char *message);
  406. Xextern void do_ofail(dbref player, const char *name, const char *message);
  407. Xextern void do_lock(dbref player, const char *name, const char *keyname);
  408. Xextern void do_unlock(dbref player, const char *name);
  409. Xextern void do_unlink(dbref player, const char *name);
  410. Xextern void do_chown(dbref player, const char *name, const char *newobj);
  411. Xextern void do_set(dbref player, const char *name, const char *flag);
  412. X
  413. X/* From speech.c */
  414. Xextern void do_wall(dbref player, const char *arg1, const char *arg2);
  415. Xextern void do_gripe(dbref player, const char *arg1, const char *arg2);
  416. Xextern void do_say(dbref player, const char *arg1, const char *arg2);
  417. Xextern void do_page(dbref player, const char *arg1, const char *arg2);
  418. Xextern void notify_except(dbref first, dbref exception, const char *msg);
  419. Xextern void notify_except2(dbref first, dbref ex1, dbref ex2, const char *msg);
  420. X
  421. X/* From stringutil.c */
  422. Xextern int string_compare(const char *s1, const char *s2);
  423. Xextern int string_prefix(const char *string, const char *prefix);
  424. Xextern const char *string_match(const char *src, const char *sub);
  425. X
  426. X/* From utils.c */
  427. Xextern int member(dbref thing, dbref list);
  428. Xextern dbref remove_first(dbref first, dbref what);
  429. X
  430. X/* From wiz.c */
  431. Xextern void do_teleport(dbref player, const char *arg1, const char *arg2);
  432. Xextern void do_force(dbref player, const char *what, char *command);
  433. Xextern void do_stats(dbref player, const char *name);
  434. X
  435. X/* From boolexp.c */
  436. Xextern int eval_boolexp(dbref player, struct boolexp *b);
  437. Xextern struct boolexp *parse_boolexp(dbref player, const char *string);
  438. X
  439. X/* From unparse.c */
  440. Xextern const char *unparse_object(dbref player, dbref object);
  441. Xextern const char *unparse_boolexp(dbref player, struct boolexp *);
  442. X
  443. X/* From compress.c */
  444. X#ifdef COMPRESS
  445. Xextern const char *compress(const char *);
  446. Xextern const char *uncompress(const char *);
  447. Xextern void init_compress(void);
  448. X#endif /* COMPRESS */
  449. END_OF_FILE
  450. if test 4348 -ne `wc -c <'externs.h'`; then
  451.     echo shar: \"'externs.h'\" unpacked with wrong size!
  452. fi
  453. # end of 'externs.h'
  454. fi
  455. if test -f 'help.c' -a "${1}" != "-c" ; then 
  456.   echo shar: Will not clobber existing file \"'help.c'\"
  457. else
  458. echo shar: Extracting \"'help.c'\" \(1137 characters\)
  459. sed "s/^X//" >'help.c' <<'END_OF_FILE'
  460. X#include "copyright.h"
  461. X
  462. X/* commands for giving help */
  463. X
  464. X#include "db.h"
  465. X#include "config.h"
  466. X#include "interface.h"
  467. X#include "externs.h"
  468. X
  469. Xint spit_file(dbref player, const char *filename)
  470. X{
  471. X    FILE *f;
  472. X    char buf[BUFFER_LEN];
  473. X    char *p;
  474. X
  475. X    if((f = fopen(filename, "r")) == NULL) {
  476. X    return (0);
  477. X    } else {
  478. X    while(fgets(buf, sizeof buf, f)) {
  479. X        for(p = buf; *p; p++) if(*p == '\n') {
  480. X        *p = '\0';
  481. X        break;
  482. X        }
  483. X        notify(player, buf);
  484. X    }
  485. X    fclose(f);
  486. X    return (1);
  487. X    }
  488. X}
  489. X
  490. Xvoid do_help(dbref player)
  491. X{
  492. X    if (!spit_file(player, HELP_FILE))
  493. X    { notify(player, "Sorry, the help file is missing right now.");
  494. X      writelog("GRIPE automatically generated for %s(%d): no help file %s\n",
  495. X           db[player].name, player, HELP_FILE);      
  496. X    }
  497. X}
  498. X
  499. Xvoid do_news(dbref player)
  500. X{ int result = 0;
  501. X
  502. X  result += spit_file(player, NEWS_FILE);
  503. X  result += spit_file(player, MOTD_FILE);
  504. X  if (Wizard(player)) result += spit_file(player, WIZARD_FILE);
  505. X
  506. X  if (result == 0)
  507. X  { notify(player, "No news today."); }
  508. X}
  509. X
  510. Xvoid do_motd(dbref player)
  511. X{
  512. X    spit_file(player, MOTD_FILE);
  513. X    if (Wizard(player)) spit_file(player, WIZARD_FILE);
  514. X}
  515. END_OF_FILE
  516. if test 1137 -ne `wc -c <'help.c'`; then
  517.     echo shar: \"'help.c'\" unpacked with wrong size!
  518. fi
  519. # end of 'help.c'
  520. fi
  521. if test -f 'help.txt' -a "${1}" != "-c" ; then 
  522.   echo shar: Will not clobber existing file \"'help.txt'\"
  523. else
  524. echo shar: Extracting \"'help.txt'\" \(1009 characters\)
  525. sed "s/^X//" >'help.txt' <<'END_OF_FILE'
  526. XThis is TinyMUD version 1.5.4, a user-extendible, multi-user adventure game.
  527. X
  528. XBasic commands: 
  529. X move/go <direction>
  530. X get/take <thing>; drop/throw <thing>
  531. X look; look <thing>; look <direction>
  532. X say <message>; whisper <player> = <message>
  533. X rob <player>; give <player> = <number of pennies>; kill <player>
  534. X inventory
  535. X help
  536. X news
  537. X @describe me = <description>
  538. X @password <oldpassword>=<newpassword>
  539. X page <player> --- tell player that you are looking for them (cost 1 penny)
  540. X gripe <message> --- Complain to the management.
  541. X home --- go home
  542. XOther commands are available for extending the universe.  Many of
  543. Xthese commands cost pennies, which you can obtain in a number of ways.
  544. XFull names of exits can be used in place of a go or move command.  The
  545. Xnames "me" and "here" are special; me means the current player, and
  546. Xhere means the current player's location.
  547. XMore information is available in the reference section of the Library,
  548. Xnorth of the Temple.
  549. XRemember, no matter how bad it gets, you can always go home.
  550. END_OF_FILE
  551. if test 1009 -ne `wc -c <'help.txt'`; then
  552.     echo shar: \"'help.txt'\" unpacked with wrong size!
  553. fi
  554. # end of 'help.txt'
  555. fi
  556. if test -f 'interface.h' -a "${1}" != "-c" ; then 
  557.   echo shar: Will not clobber existing file \"'interface.h'\"
  558. else
  559. echo shar: Extracting \"'interface.h'\" \(800 characters\)
  560. sed "s/^X//" >'interface.h' <<'END_OF_FILE'
  561. X#include "copyright.h"
  562. X
  563. X#include "db.h"
  564. X
  565. X/* these symbols must be defined by the interface */
  566. Xextern int notify(dbref player, const char *msg);
  567. Xextern int shutdown_flag; /* if non-zero, interface should shut down */
  568. Xextern void emergency_shutdown(void);
  569. X
  570. X/* the following symbols are provided by game.c */
  571. X
  572. X/* max length of command argument to process_command */
  573. X#define MAX_COMMAND_LEN 512
  574. X#define BUFFER_LEN ((MAX_COMMAND_LEN)*8)
  575. Xextern void process_command(dbref player, char *command);
  576. X
  577. Xextern dbref create_player(const char *name, const char *password);
  578. Xextern dbref connect_player(const char *name, const char *password);
  579. Xextern void do_look_around(dbref player);
  580. X
  581. Xextern int init_game(const char *infile, const char *outfile);
  582. Xextern void dump_database(void);
  583. Xextern void panic(const char *);
  584. END_OF_FILE
  585. if test 800 -ne `wc -c <'interface.h'`; then
  586.     echo shar: \"'interface.h'\" unpacked with wrong size!
  587. fi
  588. # end of 'interface.h'
  589. fi
  590. if test -f 'match.h' -a "${1}" != "-c" ; then 
  591.   echo shar: Will not clobber existing file \"'match.h'\"
  592. else
  593. echo shar: Extracting \"'match.h'\" \(1359 characters\)
  594. sed "s/^X//" >'match.h' <<'END_OF_FILE'
  595. X#include "copyright.h"
  596. X
  597. X#include "db.h"
  598. X
  599. X/* match functions */
  600. X/* Usage: init_match(player, name, type); match_this(); match_that(); ... */
  601. X/* Then get value from match_result() */
  602. X
  603. X/* initialize matcher */
  604. Xextern void init_match(dbref player, const char *name, int type);
  605. Xextern void init_match_check_keys(dbref player, const char *name, int type);
  606. X
  607. X/* match (LOOKUP_TOKEN)player */
  608. Xextern void match_player(void);
  609. X
  610. X/* match (NUMBER_TOKEN)number */
  611. Xextern void match_absolute(void);
  612. X
  613. X/* match "me" */
  614. Xextern void match_me(void);
  615. X
  616. X/* match "here" */
  617. Xextern void match_here(void);
  618. X
  619. X/* match something player is carrying */
  620. Xextern void match_possession(void);
  621. X
  622. X/* match something in the same room as player */
  623. Xextern void match_neighbor(void);
  624. X
  625. X/* match an exit from player's room */
  626. Xextern void match_exit(void);
  627. X
  628. X/* all of the above, except only Wizards do match_absolute and match_player */
  629. Xextern void match_everything(void);
  630. X
  631. X/* return match results */
  632. Xextern dbref match_result(void); /* returns AMBIGUOUS for multiple inexacts */
  633. Xextern dbref last_match_result(void); /* returns last result */
  634. X
  635. X#define NOMATCH_MESSAGE "I don't see that here."
  636. X#define AMBIGUOUS_MESSAGE "I don't know which one you mean!"
  637. X
  638. Xextern dbref noisy_match_result(void); /* wrapper for match_result */
  639. X                /* noisily notifies player */
  640. X                /* returns matched object or NOTHING */
  641. END_OF_FILE
  642. if test 1359 -ne `wc -c <'match.h'`; then
  643.     echo shar: \"'match.h'\" unpacked with wrong size!
  644. fi
  645. # end of 'match.h'
  646. fi
  647. if test -f 'restart-day' -a "${1}" != "-c" ; then 
  648.   echo shar: Will not clobber existing file \"'restart-day'\"
  649. else
  650. echo shar: Extracting \"'restart-day'\" \(726 characters\)
  651. sed "s/^X//" >'restart-day' <<'END_OF_FILE'
  652. X#!/bin/csh -f
  653. X
  654. Xset WINNER = `rpick < lottery`
  655. X
  656. Xecho "Starting Daytime Islandia, lottery winner is $WINNER..."
  657. X
  658. Xcd /clients/Islandia/lib
  659. Xif(-r islandia.db.new) then
  660. X    set input = islandia.db.new
  661. Xelse
  662. X    set input = islandia.db
  663. Xendif
  664. X
  665. Xcp /dev/null connect.txt
  666. Xif(-r connect.day) cp connect.day connect.txt
  667. Xif(-r motd.day) cp motd.day motd.txt
  668. X
  669. Xecho "" >> motd.txt
  670. Xecho "        Today's Lottery Winner is $WINNER" >> motd.txt
  671. Xecho "" >> motd.txt
  672. X
  673. X../bin/extract norecycle reachable players b1370 \
  674. X    -274 -560 -809 1384 1403 1404 1406 1505 \
  675. X    Tinker Lynx Tygling Three Janitor Mav \
  676. X    $WINNER \
  677. X    < $input > day.db
  678. X
  679. Xcp ../bin/netmud netmud.r
  680. Xecho RESTARTED DAY VERSION AT `date` >> islandia.log
  681. Xnetmud.r day.db day.db.new >>& islandia.log &
  682. END_OF_FILE
  683. if test 726 -ne `wc -c <'restart-day'`; then
  684.     echo shar: \"'restart-day'\" unpacked with wrong size!
  685. fi
  686. chmod +x 'restart-day'
  687. # end of 'restart-day'
  688. fi
  689. if test -f 'restart-night' -a "${1}" != "-c" ; then 
  690.   echo shar: Will not clobber existing file \"'restart-night'\"
  691. else
  692. echo shar: Extracting \"'restart-night'\" \(422 characters\)
  693. sed "s/^X//" >'restart-night' <<'END_OF_FILE'
  694. X#!/bin/csh -f
  695. Xcd /clients/Islandia/lib
  696. Xmv islandia.db islandia.db.old
  697. Xif(-r islandia.db.new) then
  698. X    mv islandia.db.new islandia.db
  699. Xelse
  700. X    cp islandia.db.old islandia.db
  701. Xendif
  702. X
  703. Xcp ../bin/netmud.conc netmud.c
  704. Xcp ../bin/concentrate .
  705. Xif(-r connect.night) cp connect.night connect.txt
  706. Xif(-r motd.night) cp motd.night motd.txt
  707. Xecho RESTARTED AT `date` >> islandia.log
  708. Xnice netmud.c islandia.db islandia.db.new >>& islandia.log &
  709. END_OF_FILE
  710. if test 422 -ne `wc -c <'restart-night'`; then
  711.     echo shar: \"'restart-night'\" unpacked with wrong size!
  712. fi
  713. chmod +x 'restart-night'
  714. # end of 'restart-night'
  715. fi
  716. if test -f 'rob.c' -a "${1}" != "-c" ; then 
  717.   echo shar: Will not clobber existing file \"'rob.c'\"
  718. else
  719. echo shar: Extracting \"'rob.c'\" \(4685 characters\)
  720. sed "s/^X//" >'rob.c' <<'END_OF_FILE'
  721. X#include "copyright.h"
  722. X
  723. X/* rob and kill */
  724. X
  725. X#include "db.h"
  726. X#include "config.h"
  727. X#include "interface.h"
  728. X#include "match.h"
  729. X#include "externs.h"
  730. X
  731. Xvoid do_rob(dbref player, const char *what)
  732. X{
  733. X    dbref thing;
  734. X    char buf[BUFFER_LEN];
  735. X    
  736. X    init_match(player, what, TYPE_PLAYER);
  737. X    match_neighbor();
  738. X    match_me();
  739. X    if(Wizard(player)) {
  740. X    match_absolute();
  741. X    match_player();
  742. X    }
  743. X    thing = match_result();
  744. X
  745. X    switch(thing) {
  746. X      case NOTHING:
  747. X    notify(player, "Rob whom?");
  748. X    break;
  749. X      case AMBIGUOUS:
  750. X    notify(player, "I don't know who you mean!");
  751. X    break;
  752. X      default:
  753. X    if(Typeof(thing) != TYPE_PLAYER) {
  754. X        notify(player, "Sorry, you can only rob other players.");
  755. X    } else if(db[thing].pennies < 1) {
  756. X        sprintf(buf, "%s is penniless.", db[thing].name);
  757. X        notify(player, buf);
  758. X        sprintf(buf,
  759. X            "%s tried to rob you, but you have no pennies to take.",
  760. X            db[player].name);
  761. X        notify(thing, buf);
  762. X    } else if(can_doit(player, thing,
  763. X               "Your conscience tells you not to.")) {
  764. X        /* steal a penny */
  765. X        db[player].pennies++;
  766. X        db[thing].pennies--;
  767. X        notify(player, "You stole a penny.");
  768. X        sprintf(buf, "%s stole one of your pennies!", db[player].name);
  769. X        notify(thing, buf);
  770. X    }
  771. X    break;
  772. X    }
  773. X}
  774. X
  775. Xvoid do_kill(dbref player, const char *what, int cost)
  776. X{
  777. X    dbref victim;
  778. X    char buf[BUFFER_LEN];
  779. X
  780. X    init_match(player, what, TYPE_PLAYER);
  781. X    match_neighbor();
  782. X    match_me();
  783. X    if(Wizard(player)) {
  784. X    match_player();
  785. X    match_absolute();
  786. X    }
  787. X    victim = match_result();
  788. X
  789. X    switch(victim) {
  790. X      case NOTHING:
  791. X    notify(player, "I don't see that player here.");
  792. X    break;
  793. X      case AMBIGUOUS:
  794. X    notify(player, "I don't know who you mean!");
  795. X    break;
  796. X      default:
  797. X    if(Typeof(victim) != TYPE_PLAYER) {
  798. X        notify(player, "Sorry, you can only kill other players.");
  799. X    } else if ((db[db[victim].location].flags & HAVEN) &&
  800. X           !Wizard(player)) {
  801. X        notify(player, "Sorry, this room is safe from killing.");
  802. X    } else {
  803. X        /* go for it */
  804. X        /* set cost */
  805. X        if(cost < KILL_MIN_COST) cost = KILL_MIN_COST;
  806. X
  807. X        /* see if it works */
  808. X        if(!payfor(player, cost)) {
  809. X        notify(player, "You don't have enough pennies.");
  810. X        } else if((random() % KILL_BASE_COST) < cost
  811. X              && !Wizard(victim)) {
  812. X        /* you killed him */
  813. X        sprintf(buf, "You killed %s!", db[victim].name);
  814. X        notify(player, buf);
  815. X
  816. X        /* notify victim */
  817. X        sprintf(buf, "%s killed you!", db[player].name);
  818. X        notify(victim, buf);
  819. X
  820. X        /* maybe pay off the bonus */
  821. X        if(db[victim].pennies < MAX_PENNIES) {
  822. X            sprintf(buf, "Your insurance policy pays %d pennies.",
  823. X                KILL_BONUS);
  824. X            notify(victim, buf);
  825. X            db[victim].pennies += KILL_BONUS;
  826. X        } else {
  827. X            notify(victim, "Your insurance policy has been revoked.");
  828. X        }
  829. X
  830. X        /* send him home */
  831. X        send_home(victim);
  832. X
  833. X        /* now notify everybody else */
  834. X        sprintf(buf, "%s killed %s!",
  835. X            db[player].name, db[victim].name);
  836. X        notify_except(db[db[player].location].contents, player, buf);
  837. X        } else {
  838. X        /* notify player and victim only */
  839. X        notify(player, "Your murder attempt failed.");
  840. X        sprintf(buf, "%s tried to kill you!", db[player].name);
  841. X        notify(victim, buf);
  842. X        }
  843. X    break;
  844. X    }
  845. X    }
  846. X}
  847. X
  848. Xvoid do_give(dbref player, char *recipient, int amount)
  849. X{
  850. X    dbref who;
  851. X    char buf[BUFFER_LEN];
  852. X
  853. X    /* do amount consistency check */
  854. X    if(amount < 0 && !Wizard(player)) {
  855. X    notify(player, "Try using the \"rob\" command.");
  856. X    return;
  857. X    } else if(amount == 0) {
  858. X    notify(player, "You must specify a positive number of pennies.");
  859. X    return;
  860. X    }
  861. X
  862. X    /* check recipient */
  863. X    init_match(player, recipient, TYPE_PLAYER);
  864. X    match_neighbor();
  865. X    match_me();
  866. X    if(Wizard(player)) {
  867. X    match_player();
  868. X    match_absolute();
  869. X    }
  870. X    
  871. X    switch(who = match_result()) {
  872. X      case NOTHING:
  873. X    notify(player, "Give to whom?");
  874. X    return;
  875. X      case AMBIGUOUS:
  876. X    notify(player, "I don't know who you mean!");
  877. X    return;
  878. X      default:
  879. X    if(!Wizard(player)) {
  880. X        if(Typeof(who) != TYPE_PLAYER) {
  881. X        notify(player, "You can only give to other players.");
  882. X        return;
  883. X        } else if(db[who].pennies + amount > MAX_PENNIES) {
  884. X        notify(player, "That player doesn't need that many pennies!");
  885. X        return;
  886. X        }
  887. X    }
  888. X    break;
  889. X    }
  890. X
  891. X    /* try to do the give */
  892. X    if(!payfor(player, amount)) {
  893. X    notify(player, "You don't have that many pennies to give!");
  894. X    } else {
  895. X    /* he can do it */
  896. X    sprintf(buf, "You give %d %s to %s.",
  897. X        amount,
  898. X        amount == 1 ? "penny" : "pennies",
  899. X        db[who].name);
  900. X    notify(player, buf);
  901. X    if(Typeof(who) == TYPE_PLAYER) {
  902. X        sprintf(buf, "%s gives you %d %s.",
  903. X            db[player].name,
  904. X            amount,
  905. X            amount == 1 ? "penny" : "pennies");
  906. X        notify(who, buf);
  907. X    }
  908. X
  909. X    db[who].pennies += amount;
  910. X    }
  911. X}
  912. END_OF_FILE
  913. if test 4685 -ne `wc -c <'rob.c'`; then
  914.     echo shar: \"'rob.c'\" unpacked with wrong size!
  915. fi
  916. # end of 'rob.c'
  917. fi
  918. if test -f 'sanity-check.c' -a "${1}" != "-c" ; then 
  919.   echo shar: Will not clobber existing file \"'sanity-check.c'\"
  920. else
  921. echo shar: Extracting \"'sanity-check.c'\" \(3984 characters\)
  922. sed "s/^X//" >'sanity-check.c' <<'END_OF_FILE'
  923. X#include "copyright.h"
  924. X
  925. X#include <stdio.h>
  926. X
  927. X#include "db.h"
  928. X#include "config.h"
  929. X
  930. X# define HAS_ENTRANCES 0x40000000
  931. X
  932. Xvoid check_exits(dbref i)
  933. X{
  934. X    dbref exit;
  935. X    int count;
  936. X
  937. X    count = 10000;
  938. X    for(exit = db[i].exits;
  939. X    exit != NOTHING;
  940. X    exit = db[exit].next) {
  941. X    if(exit < 0 || exit >= db_top || Typeof(exit) != TYPE_EXIT) {
  942. X        printf("%d has bad exit %d\n", i, exit);
  943. X        break;
  944. X    }
  945. X
  946. X    /* set type of exit to be really strange */
  947. X    db[exit].flags = 4;    /* nonexistent type */
  948. X
  949. X    if(count-- < 0) {
  950. X        printf("%d has looping exits\n");
  951. X        break;
  952. X    }
  953. X    }
  954. X}
  955. X
  956. Xvoid check_contents(dbref i)
  957. X{
  958. X    dbref thing;
  959. X    dbref loc;
  960. X    int count;
  961. X
  962. X    count = 10000;
  963. X    for(thing = db[i].contents;
  964. X    thing != NOTHING;
  965. X    thing = db[thing].next) {
  966. X    if(thing < 0 || thing >= db_top || Typeof(thing) == TYPE_ROOM) {
  967. X        printf("%d contains bad object %d\n", i, thing);
  968. X        break;
  969. X    } else if(Typeof(thing) == TYPE_EXIT) {
  970. X        db[thing].flags = 4; /* nonexistent type */
  971. X    } else if((loc = db[thing].location) != i) {
  972. X        printf("%d in %d but location is %d\n", thing, i, loc);
  973. X    }
  974. X    if(count-- < 0) {
  975. X        printf("%d has looping contents\n");
  976. X        break;
  977. X    }
  978. X    }
  979. X}
  980. X
  981. Xvoid check_location(dbref i)
  982. X{
  983. X    dbref loc;
  984. X
  985. X    loc = db[i].location;
  986. X    if(loc < 0 || loc >= db_top) {
  987. X    printf("%d has bad loc %d\n", i, loc);
  988. X    } else if(!member(i, db[loc].contents)) {
  989. X    printf("%d not in loc %d\n", i, loc);
  990. X    }
  991. X}
  992. X
  993. Xvoid check_owner(dbref i)
  994. X{
  995. X    dbref owner;
  996. X
  997. X    owner = db[i].owner;
  998. X    if(owner < 0 || owner >= db_top || Typeof(owner) != TYPE_PLAYER) {
  999. X    printf("Object %s(%d) has bad owner %d\n",
  1000. X           db[i].name, i, owner);
  1001. X    }
  1002. X}
  1003. X
  1004. Xvoid check_pennies(dbref i)
  1005. X{
  1006. X    dbref pennies;
  1007. X
  1008. X    pennies = db[i].pennies;
  1009. X
  1010. X    switch(Typeof(i)) {
  1011. X      case TYPE_ROOM:
  1012. X      case TYPE_EXIT:
  1013. X    break;
  1014. X      case TYPE_PLAYER:
  1015. X    if(pennies < 0 || pennies > MAX_PENNIES+100) {
  1016. X        printf("Player %s(%d) has %d pennies\n", db[i].name, i, pennies);
  1017. X    }
  1018. X    break;
  1019. X      case TYPE_THING:
  1020. X    if(pennies < 0 || pennies > MAX_OBJECT_ENDOWMENT) {
  1021. X        printf("Object %s(%d) endowed with %d pennies\n",
  1022. X           db[i].name, i, pennies);
  1023. X    }
  1024. X    break;
  1025. X    }
  1026. X}
  1027. X
  1028. Xvoid main(int argc, char **argv)
  1029. X{
  1030. X    dbref i;
  1031. X
  1032. X    if(db_read(stdin) < 0) {
  1033. X    puts("Database load failed!");
  1034. X    exit(1);
  1035. X    } 
  1036. X
  1037. X    puts("Done loading database");
  1038. X
  1039. X    for(i = 0; i < db_top; i++) {
  1040. X    check_pennies(i);
  1041. X    check_owner(i);
  1042. X    switch(Typeof(i)) {
  1043. X      case TYPE_PLAYER:
  1044. X        check_contents(i);
  1045. X        check_location(i);
  1046. X        if(Wizard(i)) printf("Wizard: %s(%d)\n", db[i].name, i);
  1047. X        if(Dark(i)) printf("Dark: %s(%d)\n", db[i].name, i);
  1048. X        if(Robot(i)) printf("Robot: %s(%d)\n", db[i].name, i);
  1049. X        if(db[i].password == NULL)
  1050. X        { printf ("Null password: %s(%d)\n", db[i].name, i); }
  1051. X        break;
  1052. X      case TYPE_THING:
  1053. X        check_location(i);
  1054. X        break;
  1055. X      case TYPE_ROOM:
  1056. X        if(Robot(i)) printf("UnRobot: %s(%d)\n", db[i].name, i);
  1057. X        check_contents(i);
  1058. X        check_exits(i);
  1059. X        break;
  1060. X    }
  1061. X    }
  1062. X
  1063. X    /* scan for unattached exits */
  1064. X    for(i = 0; i < db_top; i++) {
  1065. X    if(Typeof(i) == TYPE_EXIT) {
  1066. X        printf("Unattached exit %d\n", i);
  1067. X    }
  1068. X    }
  1069. X        
  1070. X    /* scan for unattached exits */
  1071. X    for(i = 0; i < db_top; i++) {
  1072. X    if(Typeof(i) == TYPE_EXIT) {
  1073. X        printf("Unattached exit %d\n", i);
  1074. X    }
  1075. X    }
  1076. X        
  1077. X    /*---- scan for unattached rooms ----*/
  1078. X    
  1079. X    /* Clear entry flags */
  1080. X    for(i = 0; i < db_top; i++) db[i].flags &= ~HAS_ENTRANCES;
  1081. X
  1082. X    /* For each exit, set its destination entry bit */    
  1083. X    for(i = 0; i < db_top; i++) {
  1084. X    if(Typeof(i) == TYPE_EXIT || Typeof(i) == 4) {
  1085. X        if(db[i].location >= 0) db[db[i].location].flags |= HAS_ENTRANCES;
  1086. X    }
  1087. X    }
  1088. X
  1089. X    /* Now print every room with no entrances */    
  1090. X    for(i = 0; i < db_top; i++) {
  1091. X    if(Typeof(i) == TYPE_ROOM && 
  1092. X       (db[i].flags & HAS_ENTRANCES) == 0) {
  1093. X        if (db[i].exits == NOTHING && db[i].contents == NOTHING) {
  1094. X        printf ("Room %d has no entrances, exits, or contents\n", i);
  1095. X        } else {
  1096. X        printf ("Room %d has no entrances\n", i);
  1097. X        }
  1098. X    }
  1099. X    }
  1100. X        
  1101. X    exit(0);
  1102. X}
  1103. END_OF_FILE
  1104. if test 3984 -ne `wc -c <'sanity-check.c'`; then
  1105.     echo shar: \"'sanity-check.c'\" unpacked with wrong size!
  1106. fi
  1107. # end of 'sanity-check.c'
  1108. fi
  1109. if test -f 'small.db.README' -a "${1}" != "-c" ; then 
  1110.   echo shar: Will not clobber existing file \"'small.db.README'\"
  1111. else
  1112. echo shar: Extracting \"'small.db.README'\" \(1507 characters\)
  1113. sed "s/^X//" >'small.db.README' <<'END_OF_FILE'
  1114. XNotes to new administrators using small.db:
  1115. X
  1116. X1. There are four objects of type player in small.db: Wizard(#1),
  1117. XBeaker(#2), guy(#121), and Darooha(#203).  As distributed, all have
  1118. Xthe password "potrzebie."  Wizard is the administrative player; it is
  1119. Xthe only one that has its WIZARD bit set, and it owns most of the core
  1120. Xrooms.  Beaker is included for testing.  guy and Darooha own the
  1121. X"Eastward Ho" and "Bud's" adventures; if you want to leave these
  1122. Xsamples out, you can remove them using extract.  Only the Wizard and
  1123. Xthe objects owned by the Wizard are really important...
  1124. X
  1125. X2. Small.db contains no unlinked exits; thus it will be impossible for
  1126. Xanybody who is not a WIZARD to connect new rooms to the core rooms.
  1127. XWhen TinyMUD was first started up on LANCELOT.AVALON.CS.CMU.EDU, the
  1128. XTown Square was given 9 unlinked exits (7 of the 8 cardinal directions
  1129. Xplus up and down) and was set to be LINK_OK; this allowed early
  1130. Xconstruction to take place in the neighborhood of the Town Square
  1131. Xwithout the need for administrative oversight.  
  1132. X
  1133. XWhile this policy worked well during the early lifetime of the game,
  1134. Xas the database grew the immediate surroundings of the Town Square
  1135. Xbecame rather chaotic, and only a few of the directions exits from it
  1136. Xgot much use.  It might be reasonable to build a more extensive Town
  1137. XCenter before allowing haphazard construction.
  1138. X
  1139. X--Jim Aspnes
  1140. X
  1141. XYou might want instead to get a copy of TinyBASE, a more logical and
  1142. Xcomplete basis for starting a new MUD.
  1143. X
  1144. X--Michael Mauldin (Fuzzy)
  1145. END_OF_FILE
  1146. if test 1507 -ne `wc -c <'small.db.README'`; then
  1147.     echo shar: \"'small.db.README'\" unpacked with wrong size!
  1148. fi
  1149. # end of 'small.db.README'
  1150. fi
  1151. if test -f 'stringutil.c' -a "${1}" != "-c" ; then 
  1152.   echo shar: Will not clobber existing file \"'stringutil.c'\"
  1153. else
  1154. echo shar: Extracting \"'stringutil.c'\" \(846 characters\)
  1155. sed "s/^X//" >'stringutil.c' <<'END_OF_FILE'
  1156. X#include "copyright.h"
  1157. X
  1158. X/* String utilities */
  1159. X
  1160. X#include <ctype.h>
  1161. X
  1162. X#define DOWNCASE(x) (isupper(x) ? tolower(x) : (x))
  1163. X
  1164. Xint string_compare(const char *s1, const char *s2)
  1165. X{
  1166. X    while(*s1 && *s2 && DOWNCASE(*s1) == DOWNCASE(*s2)) s1++, s2++;
  1167. X
  1168. X    return(DOWNCASE(*s1) - DOWNCASE(*s2));
  1169. X}
  1170. X
  1171. Xint string_prefix(const char *string, const char *prefix)
  1172. X{
  1173. X    while(*string && *prefix && DOWNCASE(*string) == DOWNCASE(*prefix))
  1174. X    string++, prefix++;
  1175. X    return *prefix == '\0';
  1176. X}
  1177. X
  1178. X/* accepts only nonempty matches starting at the beginning of a word */
  1179. Xconst char *string_match(const char *src, const char *sub)
  1180. X{
  1181. X    if(*sub != '\0') {
  1182. X    while(*src) {
  1183. X        if(string_prefix(src, sub)) return src;
  1184. X        /* else scan to beginning of next word */
  1185. X        while(*src && isalnum(*src)) src++;
  1186. X        while(*src && !isalnum(*src)) src++;
  1187. X    }
  1188. X    }
  1189. X
  1190. X    return 0;
  1191. X}
  1192. X
  1193. END_OF_FILE
  1194. if test 846 -ne `wc -c <'stringutil.c'`; then
  1195.     echo shar: \"'stringutil.c'\" unpacked with wrong size!
  1196. fi
  1197. # end of 'stringutil.c'
  1198. fi
  1199. if test -f 'unparse.c' -a "${1}" != "-c" ; then 
  1200.   echo shar: Will not clobber existing file \"'unparse.c'\"
  1201. else
  1202. echo shar: Extracting \"'unparse.c'\" \(3090 characters\)
  1203. sed "s/^X//" >'unparse.c' <<'END_OF_FILE'
  1204. X#include "db.h"
  1205. X
  1206. X#include "externs.h"
  1207. X#include "config.h"
  1208. X#include "interface.h"
  1209. X
  1210. Xstatic const char *unparse_flags(dbref thing)
  1211. X{
  1212. X    static char buf[BUFFER_LEN];
  1213. X    char *p;
  1214. X    const char *type_codes = TYPE_CODES;
  1215. X
  1216. X    p = buf;
  1217. X    if(Typeof(thing) != TYPE_THING) *p++ = type_codes[Typeof(thing)];
  1218. X    if(db[thing].flags & ~TYPE_MASK) {
  1219. X    /* print flags */
  1220. X    if(db[thing].flags & WIZARD) *p++ = WIZARD_MARK;
  1221. X#ifdef ROBOT_MODE
  1222. X    if(db[thing].flags & ROBOT) *p++ = ROBOT_MARK;
  1223. X#endif ROBOT_MODE
  1224. X    if(db[thing].flags & STICKY) *p++ = STICKY_MARK;
  1225. X    if(db[thing].flags & DARK) *p++ = DARK_MARK;
  1226. X    if(db[thing].flags & LINK_OK) *p++ = LINK_MARK;
  1227. X    if(db[thing].flags & ABODE) *p++ = ABODE_MARK;
  1228. X    if(db[thing].flags & TEMPLE) *p++ = TEMPLE_MARK;
  1229. X#ifdef RESTRICTED_BUILDING
  1230. X    if(db[thing].flags & BUILDER) *p++ = BUILDER_MARK;
  1231. X#endif /* RESTRICTED_BUILDING */
  1232. X    if(db[thing].flags & HAVEN) *p++ = HAVEN_MARK;
  1233. X    if(db[thing].flags & UNWANTED) *p++ = UNWANTED_MARK;
  1234. X#ifdef GENDER
  1235. X    if(Genderof(thing) == GENDER_MALE) *p++ = MALE_MARK;
  1236. X    if(Genderof(thing) == GENDER_FEMALE) *p++ = FEMALE_MARK;
  1237. X    if(Genderof(thing) == GENDER_NEUTER) *p++ = NEUTER_MARK;
  1238. X#endif /* GENDER */
  1239. X    }
  1240. X    *p = '\0';
  1241. X    return buf;
  1242. X}
  1243. X
  1244. Xconst char *unparse_object(dbref player, dbref loc)
  1245. X{
  1246. X    static char buf[BUFFER_LEN];
  1247. X
  1248. X    switch(loc) {
  1249. X      case NOTHING:
  1250. X    return "*NOTHING*";
  1251. X      case HOME:
  1252. X    return "*HOME*";
  1253. X      default:
  1254. X    if(controls(player, loc) || can_link_to(player, NOTYPE, loc)
  1255. X       || (db[loc].flags & UNWANTED)) {
  1256. X        /* show everything */
  1257. X        sprintf(buf, "%s(#%d%s)", db[loc].name, loc, unparse_flags(loc));
  1258. X        return buf;
  1259. X    } else {
  1260. X        /* show only the name */
  1261. X        return db[loc].name;
  1262. X    }
  1263. X    }
  1264. X}
  1265. X
  1266. Xstatic char boolexp_buf[BUFFER_LEN];
  1267. Xstatic char *buftop;
  1268. X
  1269. Xstatic void unparse_boolexp1(dbref player,
  1270. X                 struct boolexp *b, boolexp_type outer_type)
  1271. X{
  1272. X    if(b == TRUE_BOOLEXP) {
  1273. X    strcpy(buftop, "*UNLOCKED*");
  1274. X    buftop += strlen(buftop);
  1275. X    } else {
  1276. X    switch(b->type) {
  1277. X      case BOOLEXP_AND:
  1278. X        if(outer_type == BOOLEXP_NOT) {
  1279. X        *buftop++ = '(';
  1280. X        }
  1281. X        unparse_boolexp1(player, b->sub1, b->type);
  1282. X        *buftop++ = AND_TOKEN;
  1283. X        unparse_boolexp1(player, b->sub2, b->type);
  1284. X        if(outer_type == BOOLEXP_NOT) {
  1285. X        *buftop++ = ')';
  1286. X        }
  1287. X        break;
  1288. X      case BOOLEXP_OR:
  1289. X        if(outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND) {
  1290. X        *buftop++ = '(';
  1291. X        }
  1292. X        unparse_boolexp1(player, b->sub1, b->type);
  1293. X        *buftop++ = OR_TOKEN;
  1294. X        unparse_boolexp1(player, b->sub2, b->type);
  1295. X        if(outer_type == BOOLEXP_NOT || outer_type == BOOLEXP_AND) {
  1296. X        *buftop++ = ')';
  1297. X        }
  1298. X        break;
  1299. X      case BOOLEXP_NOT:
  1300. X        *buftop++ = '!';
  1301. X        unparse_boolexp1(player, b->sub1, b->type);
  1302. X        break;
  1303. X      case BOOLEXP_CONST:
  1304. X        strcpy(buftop, unparse_object(player, b->thing));
  1305. X        buftop += strlen(buftop);
  1306. X        break;
  1307. X      default:
  1308. X        abort();        /* bad type */
  1309. X        break;
  1310. X    }
  1311. X    }
  1312. X}
  1313. X        
  1314. Xconst char *unparse_boolexp(dbref player, struct boolexp *b)
  1315. X{
  1316. X    buftop = boolexp_buf;
  1317. X    unparse_boolexp1(player, b, BOOLEXP_CONST);    /* no outer type */
  1318. X    *buftop++ = '\0';
  1319. X
  1320. X    return boolexp_buf;
  1321. X}
  1322. X    
  1323. END_OF_FILE
  1324. if test 3090 -ne `wc -c <'unparse.c'`; then
  1325.     echo shar: \"'unparse.c'\" unpacked with wrong size!
  1326. fi
  1327. # end of 'unparse.c'
  1328. fi
  1329. if test -f 'utils.c' -a "${1}" != "-c" ; then 
  1330.   echo shar: Will not clobber existing file \"'utils.c'\"
  1331. else
  1332. echo shar: Extracting \"'utils.c'\" \(756 characters\)
  1333. sed "s/^X//" >'utils.c' <<'END_OF_FILE'
  1334. X#include "copyright.h"
  1335. X
  1336. X#include "db.h"
  1337. X
  1338. X/* remove the first occurence of what in list headed by first */
  1339. Xdbref remove_first(dbref first, dbref what)
  1340. X{
  1341. X    dbref prev;
  1342. X
  1343. X    /* special case if it's the first one */
  1344. X    if(first == what) {
  1345. X    return db[first].next;
  1346. X    } else {
  1347. X    /* have to find it */
  1348. X    DOLIST(prev, first) {
  1349. X        if(db[prev].next == what) {
  1350. X        db[prev].next = db[what].next;
  1351. X        return first;
  1352. X        }
  1353. X    }
  1354. X    return first;
  1355. X    }
  1356. X}
  1357. X
  1358. Xint member(dbref thing, dbref list)
  1359. X{
  1360. X    DOLIST(list, list) {
  1361. X    if(list == thing) return 1;
  1362. X    }
  1363. X
  1364. X    return 0;
  1365. X}
  1366. X
  1367. Xdbref reverse(dbref list)
  1368. X{
  1369. X    dbref newlist;
  1370. X    dbref rest;
  1371. X
  1372. X    newlist = NOTHING;
  1373. X    while(list != NOTHING) {
  1374. X    rest = db[list].next;
  1375. X    PUSH(list, newlist);
  1376. X    list = rest;
  1377. X    }
  1378. X    return newlist;
  1379. X}
  1380. END_OF_FILE
  1381. if test 756 -ne `wc -c <'utils.c'`; then
  1382.     echo shar: \"'utils.c'\" unpacked with wrong size!
  1383. fi
  1384. # end of 'utils.c'
  1385. fi
  1386. echo shar: End of archive 10 \(of 10\).
  1387. cp /dev/null ark10isdone
  1388. MISSING=""
  1389. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1390.     if test ! -f ark${I}isdone ; then
  1391.     MISSING="${MISSING} ${I}"
  1392.     fi
  1393. done
  1394. if test "${MISSING}" = "" ; then
  1395.     echo You have unpacked all 10 archives.
  1396.     echo ">>> now type 'sh joinspl.sh'"
  1397.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1398. else
  1399.     echo You still need to unpack the following archives:
  1400.     echo "        " ${MISSING}
  1401. fi
  1402. ##  End of shell archive.
  1403. exit 0
  1404.